package com.xitang.system.poi;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.xitang.common.bean.BizCategory;
import com.xitang.common.mapper.BizCategoryMapper;

import java.util.Map;

public class BizCategoryExcelListener extends AnalysisEventListener<BizCategory> {

    private BizCategoryMapper categoryMapper;

    public BizCategoryExcelListener(BizCategoryMapper categoryMapper) {
        this.categoryMapper = categoryMapper;
    }

    // 逐行读取excel内容
    @Override
    public void invoke(BizCategory category, AnalysisContext analysisContext) {
        System.out.println("excel内容：" + category);
        categoryMapper.insert(category);
    }

    // 读取excel表头信息
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头：" + headMap);
    }

    // 读取完之后执行
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("end");
    }
}
